package vista;

import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.GridBagLayout;

import javax.swing.ImageIcon;
import javax.swing.JPanel;

public abstract class Paneles extends JPanel{
	private ImageIcon imagen;
	private static final long serialVersionUID = -2857183965152815354L;
	protected Ventana ventana;

	public Paneles (Ventana ventana, String n) { 
		super();
		this.ventana = ventana;
		setearImagenDeFondo(n);
		setLayout(new GridBagLayout());
	}
	
	public void setearImagenDeFondo(String urlImagen) {
		imagen = new ImageIcon(getClass().getResource(urlImagen));
		this.setSize(imagen.getIconWidth(),imagen.getIconHeight());
		repaint();
	}

	@Override
	protected void paintComponent(Graphics g) {
		Dimension d = getSize();
		g.drawImage(imagen.getImage(),0,0,d.width,d.height, null);
		setOpaque(false);
		super.paintComponent(g);
	}
}
